package com.hy.mydesktop.server.rpc;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import java_cup.internal_error;
import javassist.tools.framedump;

import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUtil;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.DocumentException;
import org.springframework.web.context.WebApplicationContext;

import net.sf.gilead.configuration.ConfigurationHelper;
import net.sf.gilead.core.IPersistenceUtil;
import net.sf.gilead.core.PersistentBeanManager;
import net.sf.gilead.core.hibernate.jpa.HibernateJpaUtil;

import sun.management.GcInfoCompositeData;

import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.BeanModel;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.hy.enterprise.framework.service.spring.MySpringUtil;
import com.hy.mydesktop.client.rpc.ServiceInvoker;
import com.hy.mydesktop.server.dao.UserDao;
import com.hy.mydesktop.server.service.ComponentControllerMetaModelService;
import com.hy.mydesktop.server.service.InitGxtSystemDatas;
import com.hy.mydesktop.shared.persistence.domain.User;
import com.hy.mydesktop.shared.persistence.domain.gxt.GwtRpcModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentControllerMetaModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.MyBaseModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.LibConstants;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.MetaDataConstants;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceParameter;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceResult;
import com.hy.mydesktop.shared.rpc.util.RpcDebugUtil;
import com.hy.mydesktop.shared.util.log.MyLoggerUtil;
import com.sun.istack.internal.FinalArrayList;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
//public class ServiceInvokerImpl extends RemoteServiceServlet implements
public class ServiceInvokerImpl extends BaseRpcServiceWithSpring implements
		ServiceInvoker {

	private Log logger =LogFactory.getLog(ServiceInvokerImpl.class);
	/*
	 * @Override
	 * public List<BaseModel> invokeService(String serviceClassName, String
	 * serviceMethodName) {
	 * 
	 * //gxtComponentMetaModel.get(property, valueWhenNull);
	 * 
	 * //反射，解析field，查看gxtComponentMetaModel中是否存在当前属性，如果存在，则switch|case赋值
	 * Class c = null;
	 * Method method = null;
	 * Class[] argclass = null;
	 * Object[] parameterList =null;
	 * try {
	 * c = Class.forName(serviceClassName);
	 * Object object =c.newInstance();
	 * if (parameterList != null) {
	 * argclass =new Class[parameterList.length];
	 * for(int i=0,j=argclass.length;i<j;i++){
	 * argclass[i]=parameterList[i].getClass();
	 * }
	 * }
	 * method=c.getMethod(serviceMethodName, argclass);
	 * Object object2 = method.invoke(object , parameterList);;
	 * List<BaseModel> list = (List<BaseModel>)object2;
	 * System.err.println("(List<BaseModel>)object2"+list);
	 * for (BaseModel baseModel : list) {
	 * System.out.println(baseModel);
	 * }
	 * return (List<BaseModel>)method.invoke(object , parameterList);
	 * } catch (ClassNotFoundException e) {
	 * e.printStackTrace();
	 * } catch (InstantiationException e) {
	 * e.printStackTrace();
	 * } catch (IllegalAccessException e) {
	 * e.printStackTrace();
	 * } catch (SecurityException e) {
	 * e.printStackTrace();
	 * } catch (NoSuchMethodException e) {
	 * e.printStackTrace();
	 * } catch (IllegalArgumentException e) {
	 * e.printStackTrace();
	 * } catch (InvocationTargetException e) {
	 * e.printStackTrace();
	 * }
	 * return null;
	 * 
	 * }
	 */

	@Override
	public GxtComponentControllerMetaModel callService2(
			GxtToSeamServiceParameter gxtToSeamServiceParameter) {
		
			GxtToSeamServiceResult gxtToSeamServiceResult = new GxtToSeamServiceResult();
			gxtToSeamServiceResult.setConversationId("hello");
			
			
			
			GxtComponentControllerMetaModel componentControllerMetaModel = new GxtComponentControllerMetaModel();
			BaseModel result = new BaseModel();
			//System.err.println(result);
			System.err.println(componentControllerMetaModel);
			result.set("kl", componentControllerMetaModel);
			gxtToSeamServiceResult.setResult(result);
			/*UserDao userDao = springContext.getBean("userDao", UserDao.class);
			User user = userDao.isUser(null);
			gxtToSeamServiceResult.setConversationId("id_"+userDao.getClass());
			gxtToSeamServiceResult.setResult(user);*/
			return componentControllerMetaModel;
	}
	
	@Override
	public GxtToSeamServiceResult callService(
			final GxtToSeamServiceParameter gxtToSeamServiceParameter) {
		//MyLoggerUtil.printAsteriskDebug(getClass());
		//RpcDebugUtil.printGxtToSeamServiceParameterOfRpc(getClass(), gxtToSeamServiceParameter);
		//MyLoggerUtil.printAsteriskDebug(getClass());
		//logger.debug( "***************************************************************");
		this.printAsteriskDebug();
		this.debugPrintGxtToSeamServiceParameterOfRpc(getClass(), gxtToSeamServiceParameter);
		this.printAsteriskDebug();
		GxtToSeamServiceResult gxtToSeamServiceResult = new GxtToSeamServiceResult();
		
		resolveAndInvokeServiceFromSpring(gxtToSeamServiceParameter,gxtToSeamServiceResult);

		//test();
		//GxtToSeamServiceResult gxtToSeamServiceResult = new GxtToSeamServiceResult();
		
		return gxtToSeamServiceResult;
		
		
//		System.err.println("####ServiceInvokerImpl.callService(gxtToSeamServiceParameter) is running...........................");
//		Class c = null;
//		Method method = null;
//		//参数数组中每个类的 类名称
//		Class[] argclass = null;
//		ModelData[] parameterList = null;
//		try {
//			System.out
//					.println("gxtToSeamServiceParameter.getServiceComponentName()"
//							+ gxtToSeamServiceParameter	.getServiceComponentName());
//			c = Class.forName(gxtToSeamServiceParameter	.getServiceComponentName());
//		
//			Object object = c.newInstance();
//			//ModelData[]
//			parameterList = gxtToSeamServiceParameter.getMethodArguments();
//			System.out.println("-------------parameterList is : " + parameterList);
//			if (parameterList != null) {
//				argclass = new Class[parameterList.length];
//				for (int i = 0, j = argclass.length; i < j; i++) {
//					argclass[i] = parameterList[i].getClass();
//				}
//			}
//			method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), argclass);
//			System.out
//			.println("gxtToSeamServiceParameter.getServiceMethodName()"
//					+ method);
//			Object object2 = method.invoke(object, parameterList);
//			;
//			/**
//			 * 假定，被调用的方法method.invoke(object, parameterList)的返回值object2
//			 * 是List<BaseModel>类型
//			 */
//			//List<BaseModel> list = (List<BaseModel>) object2;
//			//System.err.println("method.invoke(object, parameterList) 的返回值，(List<BaseModel>)object2" + list);
//			//for (BaseModel baseModel : list) {
//			//	System.out.println(baseModel);
//			//}
//
//			GxtToSeamServiceResult gxtToSeamServiceResult = new GxtToSeamServiceResult();
//			gxtToSeamServiceResult.setConversationId(UUID.randomUUID()
//					.toString());
//			BaseModelData baseModelData = new BaseModelData();
//			baseModelData.set("listOfModelData", method.invoke(object,
//					gxtToSeamServiceParameter.getMethodArguments()));
//			gxtToSeamServiceResult.setResult(baseModelData);
//			System.err.println("####ServiceInvokerImpl.callService(gxtToSeamServiceParameter) is over...........................");
//			return gxtToSeamServiceResult;
//		} catch (ClassNotFoundException e) {
//			e.printStackTrace();
//		} catch (InstantiationException e) {
//			e.printStackTrace();
//		} catch (IllegalAccessException e) {
//			e.printStackTrace();
//		} catch (SecurityException e) {
//			e.printStackTrace();
//		} catch (NoSuchMethodException e) {
//			e.printStackTrace();
//		} catch (IllegalArgumentException e) {
//			e.printStackTrace();
//		} catch (InvocationTargetException e) {
//			e.printStackTrace();
//		}
//		return null;
	}

	
	private void test() {
		//gxtToSeamServiceResult.setConversationId("hello");		
		ComponentControllerMetaModelService componentControllerMetaModelService = getSpringContext().getBean("componentControllerMetaModelService", ComponentControllerMetaModelService.class);
		GxtComponentControllerMetaModel componentControllerMetaModel = componentControllerMetaModelService.findComponentControllerMetaModelByControllerMetaModelId("controllerMetaModel0");
//		GxtComponentControllerMetaModel componentControllerMetaModel = new GxtComponentControllerMetaModel();
		this.printAsteriskDebug();
		logger.debug("在由gilead处理之前，得到的componentControllerMetaModel:");
		logger.debug("before  class :"+ componentControllerMetaModel.getClass().getName());
		logger.debug("before  class :"+ componentControllerMetaModel.getList().getClass().getName());
		this.printAsteriskDebug();

		
		/*Class clazz = componentControllerMetaModel.getModels().getClass();
		for (int i = 0; i < clazz.getInterfaces().length; i++) {
			
			System.err.println("interface :"+ clazz.getInterfaces()[i]);
		}
		for (int i = 0; i < clazz.getDeclaredFields().length; i++) {
			System.err.println("field :["+i+"] "+clazz.getDeclaredFields()[i]);
			System.err.println("field.class :"+clazz.getDeclaredFields()[i].getClass());
		}*/									
		this.printAsteriskDebug();
		
		logger.debug("把得到的componentControllerMetaModel，由gilead处理，转化为:cloneComponentControllerMetaModel");
		GxtComponentControllerMetaModel cloneControllerMetaModel = (GxtComponentControllerMetaModel)beanManager.clone(componentControllerMetaModel);
		logger.debug("after   :"+ cloneControllerMetaModel.getClass().getName());
		logger.debug("after   :"+ cloneControllerMetaModel.getList().getClass().getName());
		//System.err.println("xxxxxxxxxxxxxxxxxxxxxxxafter  class :"+ cloneControllerMetaModel.getList().get(1).getGxtComponentMetaNodeModel().getComponentTypeEnum());
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//通过Xml，读取Gxt的Controller和Component的初始化信息
		/*try {
			cloneControllerMetaModel = new InitGxtSystemDatas().initGxtComponentControllerMetaModel();
		} catch (DocumentException e) {
			e.printStackTrace();
		}*/
		//System.err.println("after  class :"+ cloneControllerMetaModel.getClass().getName());
		//System.err.println("after  class :"+ cloneControllerMetaModel.getModels().getClass().getName());
		this.printAsteriskDebug();

		//componentControllerMetaModel.setModels(newList);
		//System.err.println("gileadBeanManager :"+gileadBeanManager);
		//List<GwtRpcModel> gileadList = (List<GwtRpcModel>) gileadBeanManager.clone(list);
		BaseModel result = new BaseModel();
//		System.err.println("declare classType is GwtRpcModel,but fact class :"+ componentControllerMetaModel.getModels().getClass());

		//System.err.println(result);
		System.err.println(componentControllerMetaModel);
		result.set(MetaDataConstants.GXT_COMPONENT_CONTROLLER_METAMODEL, cloneControllerMetaModel);
//		result.set(MetaDataConstants.GXT_COMPONENT_CONTROLLER_METAMODEL, componentControllerMetaModel.getBaseModel());
//		System.err.println("BaseModel 类型 "+componentControllerMetaModel.getBaseModel()+" have list(BaseModel) :"+componentControllerMetaModel.getBaseModel().get("models")+
//				" ,list[0] "+((List)componentControllerMetaModel.getBaseModel().get("models")).get(0));

//gxtToSeamServiceResult.setResult(result);
		/*UserDao userDao = springContext.getBean("userDao", UserDao.class);
		User user = userDao.isUser(null);
		gxtToSeamServiceResult.setConversationId("id_"+userDao.getClass());
		gxtToSeamServiceResult.setResult(user);*/
		
	}

	private void resolveAndInvokeServiceFromSpring(GxtToSeamServiceParameter gxtToSeamServiceParameter,GxtToSeamServiceResult gxtToSeamServiceResult) {
		System.err.println("####ServiceInvokerImpl.callService(gxtToSeamServiceParameter) is running...........................");
		Class c = null;
		Method method = null;
		//参数数组中每个类的 类名称		
		//ModelData[] parameterList = null;
		try {			
			Object object =  springContext.getBean(gxtToSeamServiceParameter.getServiceComponentName());
			c=object.getClass();
//			Method[] methods= clazz.getMethods();			
			//parameterList = gxtToSeamServiceParameter.getMethodArguments();
			//System.out.println("-------------parameterList is : " + parameterList);
//			if (parameterList != null) {
//				argclass = new Class[parameterList.length];
//				for (int i = 0, j = argclass.length; i < j; i++) {
//					argclass[i] = parameterList[i].getClass();
//				}
//			}
			
			if (gxtToSeamServiceParameter.getMethodArgumentsType().equals(MetaDataConstants.MODELDATA_ARRAY)) {
				/*if (gxtToSeamServiceParameter.getMethodArguments()==null||gxtToSeamServiceParameter.getMethodArguments().length==0) {
					
					method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), null);
				}else {
					method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), gxtToSeamServiceParameter.getMethodArguments().getClass());

				}*/
				Method[] methods= c.getMethods();

				if (gxtToSeamServiceParameter.getMethodArguments()!=null) {
					if (gxtToSeamServiceParameter.getMethodArguments() instanceof ModelData[]) {
						method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), ModelData[].class);

					} else {
						method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), gxtToSeamServiceParameter.getMethodArguments().getClass());

					}

				}else if (gxtToSeamServiceParameter.getMethodArguments2()!=null) {
					logger.error("gxtToSeamServiceParameter.getMethodArguments2():"+gxtToSeamServiceParameter.getMethodArguments2());
					if (gxtToSeamServiceParameter.getMethodArguments2() instanceof List) {
						
						method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), List.class);
					} else {
						 throw new RuntimeException("444444444444444444444444444444");

					}

				}else if (gxtToSeamServiceParameter.getArgumentValue()!=null) {
					method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), gxtToSeamServiceParameter.getArgumentValue().getClass());

				}else {
					method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), null);
					// throw new RuntimeException("444444444444444444444444444444");

				}
			}
			else if (
					gxtToSeamServiceParameter.getMethodArgumentsType().equals("string")
					||gxtToSeamServiceParameter.getMethodArgumentsType().equals("String")) {

				method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), String.class);
			}
			 else {
				 throw new RuntimeException("444444444444444444444444444444");
				//method = c.getMethod(gxtToSeamServiceParameter.getServiceMethodName(), gxtToSeamServiceParameter.getMethodArguments().getClass());
			}
			printAsteriskDebug();
			logger.debug("从Spring的bean工厂，得到名称为"+gxtToSeamServiceParameter.getServiceComponentName()+"组件（实际产生的代理类名称为"+object+"），调用的方法名称为"+method+"，");
			
			//System.out.println("gxtToSeamServiceParameter.getServiceMethodName()"+ method);
			//Object object2 = method.invoke(object, parameterList);
			;
			/**
			 * 假定，被调用的方法method.invoke(object, parameterList)的返回值object2
			 * 是List<BaseModel>类型
			 */
//			//List<BaseModel> list = (List<BaseModel>) object2;
//			//System.err.println("method.invoke(object, parameterList) 的返回值，(List<BaseModel>)object2" + list);
//			//for (BaseModel baseModel : list) {
//			//	System.out.println(baseModel);
//			//}
//
			gxtToSeamServiceResult.setConversationId(UUID.randomUUID().toString());
			BaseModel baseModel = new BaseModel();
//			baseModelData.set("listOfModelData", method.invoke(object,gxtToSeamServiceParameter.getMethodArguments()));
			
			
//			Object re= method.invoke(object,gxtToSeamServiceParameter.getMethodArguments());
			logger.info("Object re= method.invoke(object,gxtToSeamServiceParameter.getArgumentValue())");
			logger.info("method:"+method);
			logger.info("object:"+object);
			logger.info("gxtToSeamServiceParameter.getArgumentValue():"+gxtToSeamServiceParameter.getArgumentValue());
			logger.error("gxtToSeamServiceParameter.getMethodArguments():"+gxtToSeamServiceParameter.getMethodArguments());

			Object re=null;
			/*if ((gxtToSeamServiceParameter.getMethodArguments()==null
					||gxtToSeamServiceParameter.getMethodArguments().length==0)
					&&gxtToSeamServiceParameter.getArgumentName()==null) {
				re= method.invoke(object);
			}else if (gxtToSeamServiceParameter.getMethodArguments()!=null) {
				System.err.println(gxtToSeamServiceParameter.getMethodArguments());
				 re= method.invoke(object,(MyBaseModel[])gxtToSeamServiceParameter.getMethodArguments());
			}else {
				 re= method.invoke(object,gxtToSeamServiceParameter.getArgumentValue());
			}*/
			
			if (gxtToSeamServiceParameter.getMethodArguments()!=null) {
				
				 re= method.invoke(object,(Object)gxtToSeamServiceParameter.getMethodArguments());
			}else if (gxtToSeamServiceParameter.getMethodArguments2()!=null) {
				 re= method.invoke(object,gxtToSeamServiceParameter.getMethodArguments2());

			}else if (gxtToSeamServiceParameter.getArgumentValue()!=null) {
				 re= method.invoke(object,gxtToSeamServiceParameter.getArgumentValue());

			}else {
				 re= method.invoke(object);
				// throw new RuntimeException("444444444444444444444444444444");

			}
						
			
			logger.debug("调用后，得到的返回结果为"+re);
			printAsteriskDebug();			
						
			this.printAsteriskDebug();
			//logger.debug("在由gilead处理之前，得到的componentControllerMetaModel:");
			//ogger.debug("before  class :"+ componentControllerMetaModel.getClass().getName());
			//logger.debug("before  class :"+ componentControllerMetaModel.getModels().getClass().getName());
			//logger.debug("before  class :"+ componentControllerMetaModel.getList().getClass().getName());
			this.printAsteriskDebug();
									
			this.printAsteriskDebug();			
			logger.debug("把得到的componentControllerMetaModel，由gilead处理，转化为:cloneComponentControllerMetaModel");
			//BaseModel[] cloneControllerMetaModel = (BaseModel[])beanManager.clone(re);
//			List<BaseModel> cloneControllerMetaModel = (List<BaseModel>)beanManager.clone(re);
			logger.debug("after   :"+ re);
			//logger.debug("after   :"+ cloneControllerMetaModel.getModels().getClass().getName());
			//logger.debug("after   :"+ cloneControllerMetaModel.getList().getClass().getName());			
			
			baseModel.set("listOfModelData", re);
			baseModel.set("exception", null);
			gxtToSeamServiceResult.setResult(baseModel);
			logger.error("####ServiceInvokerImpl.callService(gxtToSeamServiceParameter) is over...........................");
		}catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (SecurityException e) {
				e.printStackTrace();
			} catch (NoSuchMethodException e) {
				e.printStackTrace();
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			}
		
	}

	private void printAsteriskDebug() {
		logger.debug( "***************************************************************");

	}

	private void debugPrintGxtToSeamServiceParameterOfRpc(Class clazz,GxtToSeamServiceParameter gxtToSeamServiceParameter) {
		if (gxtToSeamServiceParameter==null) {
			
			logger.debug( clazz.getName()+": gxtToSeamServiceParameter的组件名称，方法名称，参数均为空！");
			return;
		}
		logger.debug( clazz.getName()+": gxtToSeamServiceParameter的组件名称"+gxtToSeamServiceParameter.getServiceComponentName());
		logger.debug( clazz.getName()+": gxtToSeamServiceParameter的方法名称"+gxtToSeamServiceParameter.getServiceMethodName());
		if (gxtToSeamServiceParameter.getMethodArguments2()!=null) {
			int i=0;
			for (ModelData modelData:gxtToSeamServiceParameter.getMethodArguments2()) {
				logger.debug( clazz.getName()+": gxtToSeamServiceParameter的方法的参数 "+(++i)+":"+gxtToSeamServiceParameter.getMethodArguments2().toString());
				for (String propertyName : modelData.getPropertyNames()) {
					logger.debug("属性名称:"+propertyName+",属性值:"+modelData.get(propertyName));
				}
			}
		} else {

			logger.debug( clazz.getName()+": gxtToSeamServiceParameter的方法的参数为空");
		}
	}
	
	
	/*@Override
	public BaseModel callService2(BaseModel gxtToSeamServiceParameter2) {
		GxtToSeamServiceParameter gxtToSeamServiceParameter = (GxtToSeamServiceParameter)gxtToSeamServiceParameter2;
		System.out.println("=================================================");
		Class c = null;
		Method method = null;
		Class[] argclass = null;
		Object[] parameterList = null;
		try {
			System.out
					.println("gxtToSeamServiceParameter.getServiceComponentName()"
							+ gxtToSeamServiceParameter
									.getServiceComponentName());
			c = Class.forName(gxtToSeamServiceParameter
					.getServiceComponentName());
			System.out.println("Finded Class is : " + c);
			Object object = c.newInstance();
			if (parameterList != null) {
				argclass = new Class[parameterList.length];
				for (int i = 0, j = argclass.length; i < j; i++) {
					argclass[i] = parameterList[i].getClass();
				}
			}
			method = c.getMethod(gxtToSeamServiceParameter
					.getServiceMethodName(), argclass);
			Object object2 = method.invoke(object, parameterList);
			;
			List<BaseModel> list = (List<BaseModel>) object2;
			System.err.println("(List<BaseModel>)object2" + list);
			for (BaseModel baseModel : list) {
				System.out.println(baseModel);
			}

			GxtToSeamServiceResult gxtToSeamServiceResult = new GxtToSeamServiceResult();
			gxtToSeamServiceResult.setConversationId(UUID.randomUUID()
					.toString());
			BaseModelData baseModelData = new BaseModelData();
			baseModelData.set("listOfModelData", method.invoke(object,
					gxtToSeamServiceParameter.getMethodArguments()));
			gxtToSeamServiceResult.setResult(baseModelData);
			return gxtToSeamServiceResult;
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		return null;
	}
*/
	

	/*
	 * //gxtComponentMetaModel.get(property, valueWhenNull);
	 * 
	 * //反射，解析field，查看gxtComponentMetaModel中是否存在当前属性，如果存在，则switch|case赋值
	 * Class c = Class.forName("com.test.client.component.meta.ButtonModel");
	 * Field[] fields = c.getDeclaredFields();
	 * for (int i = 0; i < fields.length; i++) {
	 * // Map<String, Object> buttonAttribute = new HashMap<String, Object>()
	 * gxtComponentMetaModel.get(fields[i].getName(), null);
	 * }
	 * for (ButtonModelEnum buttonModelEnum:ButtonModelEnum.values()) {
	 * //读取gxtComponentMetaModel中Button的每一个属性
	 * 
	 * Map<ButtonModelEnum, Object> buttonAttribute = new
	 * HashMap<ButtonModelEnum, Object>();
	 * buttonAttribute.put(buttonModelEnum,
	 * gxtComponentMetaModel.get(buttonModelEnum.name().toLowerCase(), null));
	 * }
	 * Enum..valueOf(enumType, name)
	 * switch (key) {
	 * case ButtonAttributeEnum.TITLE:
	 * gxtComponentMetaModel.get(ButtonAttributeEnum.TITLE., valueWhenNull)
	 * //break; 没有break
	 * 
	 * default:
	 * break;
	 * }
	 */

	/*
	 * @Override
	 * public List<BaseModel> getBaseModle(String table) {
	 * 
	 * List<BaseModel> list = new ArrayList<BaseModel>();
	 * list.add(new RPCBaseModel("sadas","10"));
	 * list.add(new RPCBaseModel("adsssssssssssssssssssssssssssssssss", "100"));
	 * 
	 * return list;
	 * 
	 * }
	 */

}
